#ifndef __RENDER_OBJECT_H__
#define __RENDER_OBJECT_H__

#pragma once

#include "Material.h"
#include "GeometryData.h"

namespace Nezha
{
	class SceneNode;

	/** hash value for material sorting. */
	struct NEZHA_ENGINE_ENTRY RenderQueHashVal
	{
		u32 LayerVal;			// render layer
		u32 ShaderVal;
		u32 StatesVal;
		u32 GeometryVal;
		u32 MatID[MAX_NUM_SAMPLERS];
		u16 PassVal;			//
	};

	enum
	{
		MAX_NUM_MATERIAL_LAYERS = 9,
	};

	/** renderable object base. */
	class NEZHA_ENGINE_ENTRY RenderObject
	{
	public:
		virtual ~RenderObject(){}

		virtual RenderObjectType getROType() const
		{
			return ROT_NONE;
		}

		virtual const _string& getROName() const = 0;

		virtual GeometryType getType() const = 0;

		virtual SceneNode* getSpatial() = 0;

		u8 getNumMaterialLayers() const
		{
			return mNumMatLayers;
		}

		MaterialPtr getMaterial(u32 i);

		RenderLayer getRenderLayer() const
		{
			return mRenderLayer;
		}

		bool getCastShadow() const
		{
			return mCastShadow;
		}

		bool getReceiveShadow() const
		{
			return mReceiveShadow;
		}

		RenderObjectBatch getBatchType() const
		{
			return mBatchType;
		}

		virtual void setMaterial(u32 i, const MaterialPtr& mat);

		void setCastShadow(bool b);

		void setReceiveShadow(bool b);

		/** for render pipeline. */
		virtual void prepareGeometry4Pipeline(GeometryDataBatch& batch) = 0;

		virtual u32 getGeometryHash() const = 0;

		RenderObject();

	protected:
		MaterialPtr mMatLayers[MAX_NUM_MATERIAL_LAYERS];
		u8 mNumMatLayers;

		RenderLayer mRenderLayer;
		RenderObjectBatch mBatchType;

		bool mCastShadow;
		bool mReceiveShadow;
	};

}//end namespace Nezha

#endif //end __RENDER_OBJECT_H__